package autowired.controller;

import autowired.dao.UserDao;
import autowired.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;

@Controller
public class UserController {

//  属性注入 根据类型对象注入
    @Autowired
    private UserService userService;

//  属性注入 set方法注入
//    private UserService userService;
//    @Autowired
//    public void setUserService(UserService userService) {
//        this.userService = userService;
//    }

//属性注入  构造方法注入
//    private UserService userService;
//    @Autowired
//    public UserController(UserService userService) {
//        this.userService = userService;
//    }

//属性注入  形参上注入
//    private UserService userService;
//    public UserController(@Autowired UserService userService){
//        this.userService = userService;
//    }

    //属性注入  唯一有参数构造器，无需注解
//    private UserService userService;
//    public UserController(UserService userService){
//        this.userService = userService;
//    }

    public void add() {
        System.out.println("controller执行");
        userService.add();
    }
}